package windowsevent;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;

public class KeyListenerExample extends JFrame implements KeyListener {

	   JLabel jl;
	KeyListenerExample() {
	setTitle("KeyEvent Demo");
	setSize(300,300);
	Container c=getContentPane();
	c.setLayout(new FlowLayout());
	JTextField jt = new JTextField(20);
	jl = new JLabel();

	c.add(jt);
	c.add(jl);
	jt.addKeyListener(this);
	}
	@Override
	public void keyPressed(KeyEvent ke) {
		char c = ke.getKeyChar();
		String s = jl.getText() + c;
		jl.setText(s);
	}
	@Override
	public void keyReleased(KeyEvent ke) {
		// TODO Auto-generated method stub
	}
	@Override
	public void keyTyped(KeyEvent ke) {
		// TODO Auto-generated method stub	
	}
	    public static void main (String[] args)
	{
	KeyListenerExample f = new KeyListenerExample();
	f.setVisible(true);
	}
}





	
